<script src="../js/jq.js"></script>
<script src="../js/hotkeys-min.js"></script>
<script src="../js/frameready.js"></script>

<script>
	
			
	$(document).ready(function(){
		
		controller.url = "http://www.google.com";
		
		$("head").append("<base href='"+controller.url+"' />")
		
	    //$('bottomFrame').load("../comm/data.php?url="+controller.url);			
		
		$(document).bind('keydown', 'ctrl+c', controller.getSelectedText);
		$(document).bind('keydown', 'command+c', controller.getSelectedText);
		
	
	});
	
	

      $.frameReady(function(){


		$("<div>I am a div element</div>").prependTo("body");

		}, "top.content",

		{ load: [
		        {type:"script", id:"_fr", src:"/js/myscript.js", test:"myFunction"},
		        {type:"stylesheet", id:"_ss", src:"mycss.css"}
		        ] }
      );
			
	
	var controller = {
		url : null,
		bag : [],
		
		init: function(selection){
							
			this.addToBag(selection);
		},
		
		addToBag: function(selection){

			this.bag.push(this.url+":"+selection)
		},
		
		getSelectedText: function(){
			var frame = document
			
			if (frame.getSelection) {

				controller.init(frame.getSelection().toString());
				console.log('push')
			
			} else if (frame.selection) {
			
				console.log("3: "+frame.selection.createRange().text)
			
			} else {
				console.log('error')
			}
			
			
		}
		
	}
	
</script>